---
id: assoc_create
title: Creating Associations
sidebar_label: Creating
slug: /api/master/association/create
---

import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';

You can create associations on a `MasterChannel` by specifying configuration and callback interfaces.

<Tabs
groupId="language"
defaultValue="Rust"
values={[
{label: 'Rust', value: 'Rust'},
{label: 'C', value: 'C'},
{label: 'C++', value: 'C++'},
{label: 'Java', value: 'Java'},
{label: 'C#', value: 'C#'},
]}>
<TabItem value="Rust">

```rust
{{#include ../dnp3/examples/master.rs:association_create}}
```

:::note
The Rust API and the binding APIs handle associations in two different ways:
* Bindings return an association token to use on the channel. 
* Rust API returns an object that has its own methods for performing operations on the association.
:::

</TabItem>
<TabItem value="C">

```c
{{#include ../ffi/bindings/c/master_example.c:association_create}}
// check error
```

</TabItem>
<TabItem value="C++">

```cpp
{{#include ../ffi/bindings/c/master_example.cpp:association_create}}
```

</TabItem>
<TabItem value="Java">

```java
{{#include ../ffi/bindings/java/examples/src/main/java/io/stepfunc/dnp3/examples/MasterExample.java:association_create}}
```

</TabItem>
<TabItem value="C#">

```csharp
{{#include ../ffi/bindings/dotnet/examples/master/Program.cs:association_create}}
```

</TabItem>
</Tabs>

The `AssociationId` struct that is returned when adding an association is just a token. While it's required to perform operations on a particular outstation on the channel,
you don't need to keep a reference to it unless you need it to perform operations later. Allowing the `AssociationId` to be garbage collected won't remove the association from the channel.

## Removing

Remove associations from a channel by calling `MasterChannel.removeAssociation` and passing in the `AssociationId`. Doing so will stop all operations for that association.
